package com.ymatou.iapi.productmanager.testcase;

import java.util.Arrays;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonObject;
import com.ymatou.iapi.productmanager.parameter.GetAuditProductsByProductIdsBean;
import com.ymatou.iapi.productmanager.parameter.product.AddSellerProductRequest;
import com.ymatou.iapi.productmanager.service.GetAuditProductsByProductIdsCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.ProductManagerCallServiceV2;
import com.ymttest.business.service.ProductManagerCallServiceV3;
/**
*查询风控审核商品信息列表Test
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetAuditProductsByProductIds{
	private static GetAuditProductsByProductIdsBean getauditproductsbyproductidsBean;
	private static GetAuditProductsByProductIdsCall getauditproductsbyproductidsCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("查询风控审核商品信息列表Test");
	}

	@Before
	public void caseUp() {
		getauditproductsbyproductidsBean=new GetAuditProductsByProductIdsBean();
		getauditproductsbyproductidsCall=new GetAuditProductsByProductIdsCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getauditproductsbyproductidsCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetAuditProductsByProductIds_001() {
		Logger.start(true,"正确数据，成功");
		try {
			AddSellerProductRequest addProdReq =ProductManagerCallServiceV2.initAddSellerSpuProduct(3383);
			String ProductId = ProductManagerCallServiceV2.addNewProduct(addProdReq).get("Data").getAsJsonObject().get("ProductId").getAsString();
			Thread.sleep(3000);
			
			getauditproductsbyproductidsBean.setProductIdList(Arrays.asList(ProductId));
			getauditproductsbyproductidsCall.setData(getauditproductsbyproductidsBean);
			getauditproductsbyproductidsCall.callService();
			Logger.verifyEquals("200", getauditproductsbyproductidsCall.getString("Code"), "验证code");
			JsonObject ret = getauditproductsbyproductidsCall.getJsonObject().getAsJsonObject("Data").getAsJsonArray("ProductList").get(0).getAsJsonObject();
			Logger.verifyEquals(229,ret.get("spuProductId").getAsInt(),"验证SpuProductId");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}